package com.example.ivory.accountbook.Activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.example.ivory.accountbook.R;
import de.greenrobot.event.EventBus;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class AddItem extends AppCompatActivity implements View.OnClickListener {//注意
    private ViewPager viewPager;
    private ArrayList<View> pageViewList;
    private Button buttonIncome;
    private Button buttonOutcome;
    private Button buttonConfirm;
    private Button buttonPlus;
    private Button buttonChoose;
    private Button buttonCalendar;
    private Button btn;
    private LayoutInflater inflater;
    private View viewOutcome;
    private View viewIncome;
    private EditText edittextMoney;
    private int currIndex = 0;
    private int bmpW; // 滚动条宽度
    private int one;    //一倍滚动量
    private int offset = 0;
    private String stringFileName = "pick_up.txt";
    private PagerAdapter my_pager_adpater;
    private String contentInOut="支出";
    private String stringInOutWay="一般";
    private String stringPayWay="现金";
    private String stringFinal;
    private String contentMoney;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_additem);
        buttonPlus = (Button) findViewById(R.id.plus_button);
        buttonChoose = (Button) findViewById(R.id.choose_button);
        buttonCalendar = (Button) findViewById(R.id.buttonCalendar);
        buttonConfirm = (Button) findViewById(R.id.buttonConfirm);
        buttonIncome = (Button) findViewById(R.id.income_button);
        buttonOutcome= (Button) findViewById(R.id.outcome_button);
        edittextMoney= (EditText) findViewById(R.id.edittextMoney);
        btn= (Button) findViewById(R.id.button);
        viewPager = (ViewPager) findViewById(R.id.vpager);
        inflater = getLayoutInflater(); //查找布局文件
        viewIncome = inflater.inflate(R.layout.charge, null);//将xml文件包装为view
        viewOutcome = inflater.inflate(R.layout.charge2, null);
        buttonPlus.setOnClickListener(this);
        buttonChoose.setOnClickListener(this);
        buttonCalendar.setOnClickListener(this);
        buttonIncome.setOnClickListener(this);
        buttonOutcome.setOnClickListener(this);
        buttonConfirm.setOnClickListener(this);
        btn.setOnClickListener(this);
        pageViewList = new ArrayList<View>();
        pageViewList.add(viewIncome);//添加切换的页面
        pageViewList.add(viewOutcome);
        buttonChoose.setText("现金");

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-M-dd");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        buttonCalendar.setText(str);

        EventBus.getDefault().register(this);
        viewPagerAdapt();
        label();

        Intent intent=getIntent();
        stringPayWay=intent.getStringExtra("payWay");
        if(stringPayWay!=null)
            buttonChoose.setText(stringPayWay);

    }

    private void upload(){

//        try {
//
//            FileOutputStream outputStream = openFileOutput(stringFileName,
//                    Activity.MODE_APPEND);
//            outputStream.write(stringFinal.getBytes());
//            outputStream.flush();
//            outputStream.close();
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
    }

    private void read() {
//        try {
//            FileInputStream inputStream = this.openFileInput(stringFileName);
//            byte[] bytes = new byte[30];
//            ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
//            while (inputStream.read(bytes) != -1) {
//                arrayOutputStream.write(bytes, 0, bytes.length);
//            }
//            inputStream.close();
//            arrayOutputStream.close();
//            String content = new String(arrayOutputStream.toByteArray());
//            System.out.println(content);
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

    }

    @Override
    protected void onDestroy(){
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.income_button:
                viewPager.setCurrentItem(0);
                break;
            case R.id.outcome_button:
                viewPager.setCurrentItem(1);
                break;
            case R.id.buttonCalendar:
                Intent intent = new Intent(AddItem.this, calendarActivity.class);
                startActivity(intent);
                break;
            case R.id.choose_button:
                Intent intent1 = new Intent(AddItem.this, ChooseAccount.class);
                startActivity(intent1);
                this.finish();
                break;
            case R.id.plus_button:
                Intent intent2 = new Intent(AddItem.this, chargeActivity.class);
                startActivity(intent2);
                break;
            case R.id.buttonConfirm:
                sendToMain();
                this.finish();
                break;
            case R.id.button:
                read();
                break;
        }
    }

    public class MyOnPageChangeListener implements ViewPager.OnPageChangeListener {

        public void onPageSelected(int arg0) {
            Animation animation = null;
            switch (arg0) {
                case 0:
                    animation = new TranslateAnimation(one, 0, 0, 0);
                    break;
                case 1:
                    animation = new TranslateAnimation(offset, one, 0, 0);
                    break;
            }
            //arg0为切换到的页的编码
            currIndex = arg0;
            // 将此属性设置为true可以使得图片停在动画结束时的位置
            animation.setFillAfter(true);
            //动画持续时间，单位为毫秒
            animation.setDuration(200);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    }

    public void label() {
        //收入界面的按钮监听
        final ImageButton buttonMethod01 = (ImageButton) viewIncome.findViewById(R.id.button1);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod01.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod01.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "一般";
                                              }
                                          }
        );

        final ImageButton buttonMethod02 = (ImageButton) viewIncome.findViewById(R.id.button2);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod02.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod02.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "餐饮";

                                              }
                                          }
        );
        final ImageButton buttonMethod03 = (ImageButton) viewIncome.findViewById(R.id.button3);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod03.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod03.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "交通";
                                              }
                                          }
        );
        final ImageButton buttonMethod04 = (ImageButton) viewIncome.findViewById(R.id.button4);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod04.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod04.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "酒水饮料";
                                              }
                                          }
        );
        final ImageButton buttonMethod05 = (ImageButton) viewIncome.findViewById(R.id.button5);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod05.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod05.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "水果";
                                              }
                                          }
        );
        final ImageButton buttonMethod06 = (ImageButton) viewIncome.findViewById(R.id.button6);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod06.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod06.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "零食";
                                              }
                                          }
        );
        final ImageButton buttonMethod07 = (ImageButton) viewIncome.findViewById(R.id.button7);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod07.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod07.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "买菜";
                                              }
                                          }
        );
        final ImageButton buttonMethod08 = (ImageButton) viewIncome.findViewById(R.id.button8);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod08.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod08.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "衣服鞋包";
                                              }
                                          }
        );
        final ImageButton buttonMethod09 = (ImageButton) viewIncome.findViewById(R.id.button9);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod09.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod09.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "生活用品";
                                              }
                                          }
        );
        final ImageButton buttonMethod10 = (ImageButton) viewIncome.findViewById(R.id.button10);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod10.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod10.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "话费";
                                              }
                                          }
        );

        final ImageButton buttonMethod11 = (ImageButton) viewIncome.findViewById(R.id.button11);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod11.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod11.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "护肤彩妆";                                              }
                                          }
        );

        final ImageButton buttonMethod12 = (ImageButton) viewIncome.findViewById(R.id.button12);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod12.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod12.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "房租";
                                              }
                                          }
        );
        final ImageButton buttonMethod13 = (ImageButton) viewIncome.findViewById(R.id.button13);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod13.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod13.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "电影";
                                              }
                                          }
        );
        final ImageButton buttonMethod14 = (ImageButton) viewIncome.findViewById(R.id.button14);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod14.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod14.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "淘宝";
                                              }
                                          }
        );
        final ImageButton buttonMethod15 = (ImageButton) viewIncome.findViewById(R.id.button15);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod15.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                              public void onClick(View view3) {
                                                  TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                  tv.setText(buttonMethod15.getTag().toString());//获取button中填写的内容并在textView中显示
                                                  stringInOutWay = "红包";
                                              }
                                          }
        );

        buttonOutcome = (Button) findViewById(R.id.outcome_button);

        //支出界面的按钮监听

        final ImageButton buttonMethod01_ = (ImageButton) viewOutcome.findViewById(R.id.button12);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod01_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                               public void onClick(View view) {
                                                   TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                   tv.setText(buttonMethod01_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                   stringInOutWay = "工资";
                                               }
                                           }
        );
        final ImageButton buttonMethod02_ = (ImageButton) viewOutcome.findViewById(R.id.button22);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod02_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                               public void onClick(View view) {
                                                   TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                   tv.setText(buttonMethod02_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                   stringInOutWay = "生活费";
                                               }
                                           }
        );
        final ImageButton buttonMethod03_ = (ImageButton) viewOutcome.findViewById(R.id.button32);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod03_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                               public void onClick(View view) {
                                                   TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                   tv.setText(buttonMethod03_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                   stringInOutWay = "红包";
                                               }
                                           }
        );
        final ImageButton buttonMethod04_ = (ImageButton) viewOutcome.findViewById(R.id.button42);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod04_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                               public void onClick(View view) {
                                                   TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                   tv.setText(buttonMethod04_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                   stringInOutWay = "零花钱";
                                               }
                                           }
        );
        final ImageButton buttonMethod05_ = (ImageButton) viewOutcome.findViewById(R.id.button52);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod05_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                               public void onClick(View view) {
                                                   TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                   tv.setText(buttonMethod05_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                   stringInOutWay = "外快兼职";
                                               }
                                           }
        );
        final ImageButton buttonMethod06_ = (ImageButton) viewOutcome.findViewById(R.id.button62);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod06_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                               public void onClick(View view) {
                                                   TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                   tv.setText(buttonMethod06_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                   stringInOutWay = "投资收入";
                                               }
                                           }
        );
        final ImageButton buttonMethod07_ = (ImageButton) viewOutcome.findViewById(R.id.button72);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod07_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                               public void onClick(View view) {
                                                   TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                   tv.setText(buttonMethod07_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                   stringInOutWay = "将金";
                                               }
                                           }
        );
        final ImageButton buttonMethod08_ = (ImageButton) viewOutcome.findViewById(R.id.button82);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod08_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                               public void onClick(View view) {
                                                   TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                   tv.setText(buttonMethod08_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                   stringInOutWay = "报销";
                                               }
                                           }
        );
        final ImageButton buttonMethod09_ = (ImageButton) viewOutcome.findViewById(R.id.button92);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod09_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                               public void onClick(View view) {
                                                   TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                   tv.setText(buttonMethod09_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                   stringInOutWay = "现金";
                                               }
                                           }
        );

        final ImageButton buttonMethod010_ = (ImageButton) viewOutcome.findViewById(R.id.button102);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod010_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                                public void onClick(View view) {
                                                    TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                    tv.setText(buttonMethod010_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                    stringInOutWay = "退款";
                                                }
                                            }
        );
        final ImageButton buttonMethod011_ = (ImageButton) viewOutcome.findViewById(R.id.button112);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod011_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                                public void onClick(View view) {
                                                    TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                    tv.setText(buttonMethod011_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                    stringInOutWay = "支付宝";
                                                }
                                            }
        );
        final ImageButton buttonMethod012_ = (ImageButton) viewOutcome.findViewById(R.id.button122);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod012_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                                public void onClick(View view) {
                                                    TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                    tv.setText(buttonMethod012_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                    stringInOutWay = "其他";
                                                }
                                            }
        );
        final ImageButton buttonMethod013_ = (ImageButton) viewOutcome.findViewById(R.id.button132);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod013_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                                public void onClick(View view) {
                                                    TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                    tv.setText(buttonMethod013_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                    stringInOutWay = "其他";
                                                }
                                            }
        );
        final ImageButton buttonMethod014_ = (ImageButton) viewOutcome.findViewById(R.id.button142);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod014_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                                public void onClick(View view) {
                                                    TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                    tv.setText(buttonMethod014_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                    stringInOutWay = "其他";
                                                }
                                            }
        );

        final ImageButton buttonMethod015_ = (ImageButton) viewOutcome.findViewById(R.id.button152);
        //点击按钮，让按钮内容显示在界面上方
        buttonMethod015_.setOnClickListener(new View.OnClickListener() {       //设置按钮单击事件
                                                public void onClick(View view) {
                                                    TextView tv = (TextView) findViewById(R.id.textView);//获取textView组件
                                                    tv.setText(buttonMethod015_.getTag().toString());//获取button中填写的内容并在textView中显示
                                                    stringInOutWay = "其他";
                                                }
                                            }
        );
    }

    public void onEventMainThread(FirstEvent event){
        String msg=event.getMsg();
        //Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
        buttonCalendar.setText(msg);
    }

    public void viewPagerAdapt(){
        my_pager_adpater = new PagerAdapter() {
            @Override
            //获取当前窗体界面数函数
            public int getCount() {
                return pageViewList.size();
            }

            @Override
            //判断是否由对象生成界面
            public boolean isViewFromObject(View arg0, Object arg1) {
                return arg0 == arg1;
            }

            //使从ViewGroup中移出当前view
            public void destroyItem(View arg0, int arg1, Object arg2) {
                ((ViewPager) arg0).removeView(pageViewList.get(arg1));
            }


            //返回一个对象，这个对象表明了PagerAdapter适配器选择哪个对象放在当前的ViewPager中
            public Object instantiateItem(View arg0, int arg1) {
                ((ViewPager) arg0).addView(pageViewList.get(arg1));
                return pageViewList.get(arg1);
            }
        };//数据适配器
        viewPager.setAdapter(my_pager_adpater);//绑定适配器
        viewPager.setCurrentItem(0);//设置viewPager的初始界面为第一个界面
        viewPager.addOnPageChangeListener(new MyOnPageChangeListener());//添加切换界面的监听器
    }

    public void sendToMain(){
        contentMoney = edittextMoney.getText().toString();
        String contentWallet;
        if(currIndex==0){
            contentInOut="支出";
        }else{
            contentInOut="收入";
        }
        if(stringPayWay==null)stringPayWay="现金";
        stringFinal=contentInOut+contentMoney+stringInOutWay+stringPayWay+buttonCalendar.getText();
        EventBus.getDefault().post(new SecondEvent(stringFinal));
        //Toast.makeText(this, stringFinal, Toast.LENGTH_LONG).show();
    }
}
